(function () {
	var controllerWorker;
	var game;
	
	window.runContollerThread = function () {
		controllerWorker = new Worker("js/controller.js");
		controllerWorker.onmessage = function (e) {
			game.doCommand(e.data);
		};
	};

	window.createNewGame = function (scenarioName, id, totalTimeOfGame) {
		game = new Game();
		//$.getJSON("scenarios?name=" + scenarioName, function (scenario) {
		controllerWorker.postMessage({
				command : "setScenario",
				params : {
					scenario : 'scenario',
					totalTimeOfGame : totalTimeOfGame
				}
			});
		//});
	}
	runContollerThread();
	createNewGame();
})();
